package com.code;

/**
 * 贪心算法取最优活动时间
 * Created by lucky on 2018/10/10.
 */
public class Code9 {
    public static void main(String[] args) {
        int[] s = new int[]{1,3,0,5,3,5,6,8,8,2,12};
        int[] f = new int[]{4,5,6,7,8,9,10,11,12,13,14};
        int length = 11;
        int[] ints = txActiving(s, f, length);
        for (int i = 0 ; i < ints.length ; i++){
            System.out.println(ints[i]);
        }

    }

    public static int[] txActiving(int[] s , int[] f , int length){
        int[] a = new int[length];
        a[0] = 1;
        int i = 0;
        int j = 1;
        for(int m = 1 ; m < length ; m++){
            if(s[m] >= f[i]){
                i = m;
                a[j] = m +1;
                j++;
            }
        }
        return a;
    }
}
